package com.atguigu.lease.web.admin.custom.config;

import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.model.enums.ReleaseStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class StringToReleaseStatusConverter implements Converter<String, ReleaseStatus> {
    @Override
    public ReleaseStatus convert(String code) {

        for (ReleaseStatus value : ReleaseStatus.values()) {
            if (value.getCode().equals(Integer.valueOf(code))) {
                return value;
            }
        }
        throw new IllegalArgumentException("code非法");
    }
}